package com.hy.main.handler;


import cn.hutool.core.util.ObjectUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * 策略工厂
 * @Author yang DongYong
 * @Date 2023/3/2 - 03 - 02 - 20:24
 * @Description: com.hy.main.handler
 * @version: 1.0
 */
public class StrategyFactory {
  private static Map<Integer, AbstractHandle> strategyMap = new HashMap();

  public static AbstractHandle getInvokeStrategy(Integer payType) {
        return  strategyMap.get(payType);
  }

  public static  void register(Integer payType, AbstractHandle handler) {
      if (ObjectUtil.isNull(payType) || ObjectUtil.isNull(handler)) {
          throw new RuntimeException("策略不能为空");
      }
      strategyMap.put(payType, handler);
  }

}
